$(function() {
	// 获取到cookie
	var cookieName = $.cookie('username')
	var cookieImg = $.cookie('img')
		//console.log($.cookie('img'))
	if(cookieImg) {
		// onerror当文件加载失败时会触发这个事件
		var header = '<img src="' + cookieImg + '" onerror="this.src=\'images/user.png\'">'
		$('#user').empty().html(header + cookieName)
	}

	//退出删除cookie
	//console.log($.cookie())
	$('.dropdown-menu li').last().click(function() {
		$.removeCookie('username')
		$.removeCookie('img')
		$.get('/back', function(data) {
			console.log(data)
			if(data.code == 'success') {
				location.href = '/'
			}
		})
	})
})